
package cc.ufinity.networkdiagnose.adapter;


import android.app.Activity;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import cc.ufinity.networkdiagnose.view.R;


public class MyAdapter extends BaseAdapter{
	
	private Activity ctx;
	private int[] icons;
	private String[] texts;
	
	private LayoutInflater mInflater;
	
	public MyAdapter(Activity ctx, int[] icons, String[] texts){
		this.ctx = ctx;
		this.icons = icons;
		this.texts = texts;
		mInflater = LayoutInflater.from(ctx);
	}

	 
	public int getCount() {
		return texts.length;
	}

	public Object getItem(int position) {
		return null;
	}

	public long getItemId(int position) {
		return position;
	}
	
	public View getView(int position, View convertView, ViewGroup parent) {
		convertView = mInflater.inflate(R.layout.vlist, null);
		TextView text = (TextView)convertView.findViewById(R.id.title);
		text.setTextColor(Color.WHITE);
		text.setText(texts[position]);
		ImageView image=(ImageView)convertView.findViewById(R.id.img);
		Drawable draw = ctx.getResources().getDrawable(icons[position]);
		image.setBackgroundDrawable(draw);
		//draw.setBounds(0, 3, draw.getIntrinsicWidth(), draw.getIntrinsicHeight());
	//	draw.setBounds(0, 3, 45, 45);
		//text.setCompoundDrawables(null, draw, null, null);
		
		return convertView;
	}
}
